package com.helloworld.fiberflax;

import com.helloworld.fiberflax.inventory.GuiElementLoader;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import javax.annotation.Nullable;

import static com.helloworld.fiberflax.Fiberflax.FIBERFLAX_CREATIVE_TAB;

public class FiberflaxBag extends Item {

    public FiberflaxBag() {
        super();
        setCreativeTab(FIBERFLAX_CREATIVE_TAB);
        setRegistryName(new ResourceLocation(Fiberflax.MODID, "item_fiberflax_bag"));
        setUnlocalizedName("item_fiberflax_bag");
        setMaxStackSize(1);
    }

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {

        if (!worldIn.isRemote) {
            if (playerIn.isSneaking()) {
                int id = GuiElementLoader.GUIFiberflaxBag;
                playerIn.openGui(Fiberflax.instance, id, worldIn, 0, 0, 0);
            }

        }
        return new ActionResult<>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
    }
}

